import { combineReducers } from "redux"
import { rootCom, RootNavigator } from "../AppNavigator"

import appReducer from "../../store/reducer"


const navState = RootNavigator.router.getStateForAction(RootNavigator.router.getActionForPathAndParams(rootCom))

const navReducer = (state = navState, action) => {
    const nextState = RootNavigator.router.getStateForAction(action, state) // 如果`nextState`为null或未定义，只需返回原始`state`
    return nextState || state
}

const index = combineReducers({
    nav: navReducer,
    app: appReducer
})
            
export default index